package org.shel.data

/**
 * Represents a datasource to retrieve player information
 */
trait PlayerDaoTrait {

    /**
     * Get the player information for the given player
     *
     * @param id The identifier of the player to retrieve
     * @return The player's information if it exists
     */
    def get(id:String) : Option[Player]

    /**
     * Get the historical readings for the given player
     *
     * @param id The identifier of the player to get history for
     * @param count The number of history readings to retrieve
     * @return The player's historical sensor readings
     */
    def getHistory(id:String, count:Int) : List[Reading]

    /**
     * Get the historical readings for the given player
     *
     * @param id The identifier of the player to add the history for
     * @param history The historical reading to insert
     * @return The reading with its new identifier
     */
    def insertHistory(id:String, reading:Reading) : Reading

    /**
     * Retrieve a list of currently available players
     *
     * @return A list of the available players
     */
    def list() : List[Player]

    /**
     * Update a given player's information
     *
     * @param player The player information to update
     * @return The updated player information
     */
    def update(player:Player) : Player

    /**
     * Insert a new player into the database
     *
     * @param player The player information to update
     * @return The player with its new identifier
     */
    def insert(player:Player) : Player
}
